namespace BuildServer.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.BuildDefinitions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        Platform = c.String(nullable: false),
                        IsNightly = c.Boolean(nullable: false),
                        BuildTemplate_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BuildTemplates", t => t.BuildTemplate_Id, cascadeDelete: true)
                .Index(t => t.BuildTemplate_Id);
            
            CreateTable(
                "dbo.BuildTemplates",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        WorkingDirectory = c.String(nullable: false),
                        BuildScript = c.String(nullable: false),
                        BuildProps = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.BuildProperties",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Value = c.String(),
                        BuildDefinition_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BuildDefinitions", t => t.BuildDefinition_Id, cascadeDelete: true)
                .Index(t => t.BuildDefinition_Id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.BuildProperties", new[] { "BuildDefinition_Id" });
            DropIndex("dbo.BuildDefinitions", new[] { "BuildTemplate_Id" });
            DropForeignKey("dbo.BuildProperties", "BuildDefinition_Id", "dbo.BuildDefinitions");
            DropForeignKey("dbo.BuildDefinitions", "BuildTemplate_Id", "dbo.BuildTemplates");
            DropTable("dbo.BuildProperties");
            DropTable("dbo.BuildTemplates");
            DropTable("dbo.BuildDefinitions");
        }
    }
}
